package whatssodifferent;

import java.io.BufferedInputStream;
import java.io.DataInputStream;
import java.io.File;
import java.io.FileInputStream;

public class Main {

    public static void main(String[] args) {

        for (int i=1;i<16; i++) {
        
        String output_s = "./../Prototype/Tests/test" + i + "/test" + i + "_out.txt";
        String original_s =  "./../Prototype/Tests/test" + i + "/original" + i + ".txt";
        System.out.println("-------------------------------\nDigiJoe\n Prototype\nby Joez" + "\n-------------------------------\nProto output ( " + output_s +  " ) [A prototipus altal adott eredmeny (" + output_s + ") fajl tartalma] " +
                "\nOriginal output (" + original_s + "):" +
                "[Az altalunk elore elkeszitett helyes kimeneti fajl (original.txt) tartalma]");
        
        
        File original = new File(original_s);
        FileInputStream fis_original = null;
        BufferedInputStream bis_original = null;
        DataInputStream dis_original = null;

        File output = new File(output_s);
        FileInputStream fis_output = null;
        BufferedInputStream bis_output = null;
        DataInputStream dis_output = null;
        try {
            fis_original = new FileInputStream(original);

            // Here BufferedInputStream is added for fast reading.
            bis_original = new BufferedInputStream(fis_original);
            dis_original = new DataInputStream(bis_original);

            fis_output = new FileInputStream(output);

            // Here BufferedInputStream is added for fast reading.
            bis_output = new BufferedInputStream(fis_output);
            dis_output = new DataInputStream(bis_output);

            boolean right = true;
            int cnt = 0;

            while (dis_output.available() != 0) {
                String line = dis_output.readLine();
                String line2 = dis_original.readLine();

                if (!line.equals(line2)) {
                    cnt++;
                    right = false;
                    System.out.println("!! " + line + " !!");
                    System.out.println("Should be:\n// " + line2 + " //");
                }
            }

            if (right) {
                System.out.println("\n\n" + cnt + " Errors found!");
            } else {
                System.out.println("\n\nWhatsSoDifferent found no errors, have a good day!");
            }

        } catch (Exception ex) { System.out.println(ex.getMessage());
        }
    }
    }
}
